#pragma once

#include "Protocol.hpp"

class NetCal
{
public:
    Response cal(Request& req)
    {
        int infoCode = 0;
        int result = 0;

        switch (req.getOper())
        {
        case '+':
            result = req.getX() + req.getY();            
            break;
        case '-':
            result = req.getX() - req.getY();            
            break;
        case '*':
            result = req.getX() * req.getY();            
            break;
        case '/':
            if (req.getY() == 0)
            {
                infoCode = 1;
            }
            else
            {
                result = req.getX() / req.getY();            
            }
            break;
        case '%':
            if (req.getY() == 0)
            {
                infoCode = 2;
            }
            else
            {
                result = req.getX() % req.getY();            
            }
            break;
        default:
            infoCode = 3;
            break;
        }

        return { infoCode, result };
    }
};
